package com.ruoyi.pcwl.controller;

import java.util.List;

import com.ruoyi.pcwl.domain.query.HotelRoomQuery;
import com.ruoyi.pcwl.domain.HotelRoom;
import com.ruoyi.pcwl.domain.vo.Result;
import com.ruoyi.pcwl.service.HotelRoomService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * 商铺环境信息 Controller
 */

@Api(tags = "房型信息控制层")
@RestController("hotelRoomController")
@RequestMapping("/hotelRoom")
public class HotelRoomController extends BaseController{

	@Resource
	private HotelRoomService hotelRoomService;
	/**
	 * 根据条件分页查询
	 */
	@ApiOperation("根据条件分页查询")
	@GetMapping("/loadDataList")
	public Result loadDataList(HotelRoomQuery query){
		return Result.ok(hotelRoomService.selectPage(query));
	}

	/**
	 * 新增
	 */
	@ApiOperation("新增")
	@PostMapping("/add")
	public Result add(@RequestBody HotelRoom bean) {
		hotelRoomService.add(bean);
		return Result.ok(null);
	}

	/**
	 * 批量新增
	 */
	@ApiOperation("批量新增")
	@PostMapping("/addBatch")
	public Result addBatch(@RequestBody List<HotelRoom> listBean) {
		hotelRoomService.addBatch(listBean);
		return Result.ok(null);
	}

	/**
	 * 批量新增/修改
	 */
	@ApiOperation("批量新增/修改")
	@PostMapping("/addOrUpdateBatch")
	public Result addOrUpdateBatch(@RequestBody List<HotelRoom> listBean) {
		hotelRoomService.addBatch(listBean);
		return Result.ok(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@ApiOperation("根据Id查询对象")
	@GetMapping("/getHotelRoomById/{id}")
	public Result getHotelRoomById(@PathVariable Long id) {
		return Result.ok(hotelRoomService.getHotelRoomById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@ApiOperation("根据Id修改对象")
	@PutMapping("/updateHotelRoomById/{id}")
	public Result updateHotelRoomById(@RequestBody HotelRoom bean,@PathVariable Long id) {
		hotelRoomService.updateHotelRoomById(bean);
		return Result.ok(null);
	}

	/**
	 * 根据Id删除
	 */

	@ApiOperation("根据Id删除")
	@DeleteMapping("/deleteHotelRoomById/{id}")
	public Result deleteHotelRoomById(@PathVariable Long id) {
		hotelRoomService.deleteHotelRoomById(id);
		return Result.ok(null);
	}
}
